/**
 * 
 */
package com.celephais.common.client.ui;

import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Eugene Shen
 * The only difference between this and a DockPanel is that a DockPanel throws
 * an exception if you try to add another CENTER widget, this one simply
 * replaces the original CENTER widget.
 */
public class CommonContainerPanel extends DockPanel {

//	private static final CommonContainerPanel instance = new CommonContainerPanel();
	private Widget centerWidget = null;
	
	public CommonContainerPanel() {
		super();
	}

//	public static CommonContainerPanel getInstance() {
//		return instance;
//	}
	
	@Override
	public void add(Widget widget, DockLayoutConstant dir) {
		if (dir == CENTER) {
			if (centerWidget != null) {
				this.remove(centerWidget);
			}
			super.add(widget, dir);
			centerWidget = widget;
		}
		else {
			super.add(widget, dir);
		}
	}
}
